library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(plotly)
##
## 载入程辑包:'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(here)
## here() starts at D:/internship/internship-reproductive-rights
library(readr)
library(ggplot2)
library(themes360info)
## Warning: ! Preferred font, ITC Franklin Gothic, not found. Using Libre Franklin as a
## fallback.
## ℹ Specify a different font to use with 360info themes by calling
## register_360fonts() or by setting options("themes360info.franklin.pref") to
## either "itc" or "libre" (or "none" to disable automatic font loading).
library(dplyr)
fertility_develop <- read_csv(here("data", "fertility_development.csv")) %>%
pivot_longer(-Region,names_to = "Years", values_to = "number")
## Rows: 7 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Region
## dbl (14): 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, ...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
line_develop<- ggplot(fertility_develop, aes(x = Years, y = number, color = Region)) +geom_point()+
geom_line(aes(group = 1))+
# facet_wrap(~Region) +
theme_bw() + theme(axis.text.x = element_text(angle = 90)) +
ggtitle("Trend for number of birth of each development group
")
ggplotly(line_develop)
#数据解释看fertility的数据的最后一页
fertility_income <- read_csv(here("data", "worldbank_incomegroup.csv")) %>%
pivot_longer(-Region,names_to = "Years", values_to = "number")
## Rows: 6 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Region
## dbl (14): 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, ...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
line_income<- ggplot(fertility_income, aes(x = Years, y = number, color = Region)) +
# geom_point()+
geom_line(aes(group = 1))+
# facet_wrap(~Region) +
theme_bw() + theme(axis.text.x = element_text(angle = 90)) +
ggtitle("Trend for each continent over time of top 5 key crop yields")
ggplotly(line_income)
#数据解释看fertility的数据的最后一页
fertility_geographic <- read_csv(here("data", "worldbank_geographic.csv")) %>%
pivot_longer(-Region,names_to = "Years", values_to = "number")
## Rows: 6 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Region
## dbl (14): 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, ...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
line_geo<- ggplot(fertility_geographic, aes(x = Years, y = number, color = Region)) +
# geom_point()+
geom_line(aes(group = 1))+
# facet_wrap(~Region) +
theme_bw() + theme(axis.text.x = element_text(angle = 90)) +
ggtitle("Trend for each continent over time of top 5 key crop yields")+theme_360()
ggplotly(line_geo)
把这几张图放一起